package com.example.lanouhn.bantangapp.activities.activities;

import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import com.example.lanouhn.bantangapp.R;

/**
 * Created by lanouhn on 16/7/26.
 */
public class Avatar_SetUp_Feedback_Activity extends Activity {

    private ImageView back;//返回

    private EditText et_content;//内容输入框

    private  EditText et_phone;//输入手机号/QQ号

    private TextView tv_send; //发送
    private ProgressBar progressbar; //转转转
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.avatar_setup_feedback);
        back = (ImageView) findViewById(R.id.back);
        et_content= (EditText) findViewById(R.id.et_content);
        et_phone= (EditText) findViewById(R.id.et_phone);
        tv_send = (TextView) findViewById(R.id.tv_send);
        progressbar = (ProgressBar) findViewById(R.id.progressbar);
        initLinstener();

    }

    /**
     * 监听跳转
     */
    private void initLinstener() {
        //返回
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        //内容输入框
        et_content.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

                if(et_content.getText().toString().trim().length()>0&&et_phone.getText().toString().trim().length()>0){
                    tv_send.setTextColor(getResources().getColor(R.color.colorAccent));
                    tv_send.setClickable(true);//设置发送按钮可以点击
                }else{
                    tv_send.setTextColor(getResources().getColor(R.color.blank_gray));
                    tv_send.setClickable(false);//设置发送按钮不能点击
                }
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });

//输入手机号/qq号
        et_phone.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

                if(et_content.getText().toString().trim().length()>0&&et_phone.getText().toString().trim().length()>0){
                    tv_send.setTextColor(getResources().getColor(R.color.colorAccent));
                    tv_send.setClickable(true);//设置发送按钮可以点击
                }else{
                    tv_send.setTextColor(getResources().getColor(R.color.blank_gray));
                    tv_send.setClickable(false);//设置发送按钮不能点击
                }
            }

            @Override
            public void afterTextChanged(Editable editable) {

                //发送成功消息
                tv_send.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        Toast.makeText(Avatar_SetUp_Feedback_Activity.this,R.string.avatar_setup_feedback_e,Toast.LENGTH_SHORT).show();
                        progressbar.setVisibility(View.VISIBLE);
                        finish();
                    }
                });
            }
        });


    }


}
